<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 使用reduce实现数组去重 -->
    <script>
        // 定义一个数组
        var arr=[1,4,5,7,4,1,8,,9,8]

        var res=arr.reduce(function(pre,cur){
            return (pre.indexOf(cur) === -1) ? pre.concat(cur) : pre
        },[])
    </script>
</body>
</html>